package org.wlw.exception;

public class TestException {
    public static void main(String[] args) {
//        FileInputStream fis = new FileInputStream("a.txt");
        try {
            System.out.println("程序开始");
            int a = 10;
            int b = 0;
            int c = divide(a, b);
            System.out.println("结果:" + c);
        } catch (NullPointerException e) {
            System.out.println("发现空指针");
            e.printStackTrace();//打印错误路径
        }
        System.out.println("程序结束");
    }

    public static int divide(int a,int b) {
        int rel = 0;
        try{
            System.out.println("\t\tdivide 开始");
            String str = null;
            str.trim();
            rel = a/b;
            System.out.println("\t\tdivide 结束");
        } catch (ArithmeticException e) {
            System.out.println("呃呃呃！发现错误:"+e.getMessage());
        } catch (NullPointerException e) {
            System.out.println("divide中发现了空指针");
        }
        return rel;
    }
}
